<template>
  <!-- 真警dialog-->
  <el-dialog
    title="批量研判"
    :visible.sync="isbatchJudge"
    width="560px"
    @open="openFunc"
    :before-close="resetFun"
    class="dialog-class1 dialogInput"
  >
    <el-row>
      <el-form :model="ruleForm" label-width="75px" :rules="rules">
        <el-form-item label="研判结果" prop="selectOperation">
          <el-radio-group v-model="ruleForm.selectOperation">
            <el-radio :label="1">真警</el-radio>
            <el-radio :label="0">误报</el-radio>
          </el-radio-group>
        </el-form-item>
        <div class="formSpan">
          将选中的告警事件研判为<span>{{
            operationType(ruleForm.selectOperation)
          }}</span>
        </div>
        <el-form-item label="研判说明">
          <el-input
            v-model="ruleForm.remark"
            type="textarea"
            resize="none"
            style="height: 60px; width: 360px"
            maxlength="200"
            placeholder="请输入"
          ></el-input>
        </el-form-item>
      </el-form>
    </el-row>
    <div slot="footer" class="dialog-footer" style="display: inline-flex">
      <el-button @click="submitFun" :loading="submitLoading" type="primary"
        >确定</el-button
      >
      <el-button @click="resetFun" style="margin-left: 12px">取消</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { batchJudgeWarningOrder } from "@/api/modules/eventManagement/eventManagement";

export default {
  name: "batchJudgeDialog",
  data() {
    return {
      selectOperation: 1,
      ruleForm: {
        trueWarnDesc: "",
        falseWarnDesc: "",
        desc: "",
        selectOperation: 1,
        remark: "",
      },
      rules: {
        desc: [{ required: true, message: "研判说明不能为空" }],
        selectOperation: [{ required: true, message: "研判结果不能为空" }],
      },
      submitLoading: false,
      remark: "",
    };
  },
  props: {
    isbatchJudge: {
      type: Boolean,
      default: false,
    },
    selectList: {
      type: Array,
      default: [],
    },
  },

  methods: {
    openFunc() {
      // this.init();
      this.selectOperation = 1;
    },
    changeOperation(val) {
      this.selectOperation = val;
    },
    operationType(val) {
      switch (val) {
        case 1:
          return "真警";
        case 0:
          return "误报";
        case 3:
          return "重复告警";
      }
    },
    //提交
    submitFun() {
      let params = {
        warningOrderList: [],
        tenantId: this.$store.getters.userInfo.tenantId,
        judgeResult: this.ruleForm.selectOperation,
        remark: this.ruleForm.remark,
        // remark: this.ruleForm.desc,
      };
      this.selectList.forEach((item) => {
        params.warningOrderList.push({
          warningOrderId: item.orderId,
          flowId: item.flowId,
          currentLink: item.linkId,
          warningSource: item.warningSource,
          templateId: item.flowTemplate,
          gridId: item.gridId,
        });
      });
      this.submitLoading = true;
      batchJudgeWarningOrder(params)
        .then((res) => {
          if (res.code == 200) {
            this.$message.success("批量研判成功");
            this.$emit("loadInit");
            this.$emit("batchJudgeFun", false);
            this.$emit("resetSelect");
          } else {
            this.$message.warning(res.msg);
          }
          this.submitLoading = false;
        })
        .catch((e) => {
          this.submitLoading = false;
        });
      this.ruleForm.remark = "";
      this.ruleForm.selectOperation = 1;
      // this.$refs.form.validate((valid) => {
      //   if (valid) {
      //     let params = {
      //       warningOrderList: [],
      //       tenantId: this.$store.getters.userInfo.tenantId,
      //       judgeResult: this.selectOperation,
      //       remark: this.ruleForm.desc,
      //     };
      //     this.selectList.forEach((item) => {
      //       params.warningOrderList.push({
      //         warningOrderId: item.orderId,
      //         flowId: item.flowId,
      //         currentLink: item.linkId,
      //       });
      //     });
      //     batchJudgeWarningOrder(params).then((res) => {
      //       if (res.code == 200) {
      //         this.$message.success("批量研判成功");
      //         this.$emit("loadInit");
      //         this.$emit("batchJudgeFun", false);
      //         this.$emit("resetSelect");
      //       } else {
      //         this.$message.warning(res.msg);
      //       }
      //     });
      //   }
      // });
    },
    resetFun() {
      this.$emit("batchJudgeFun", false);
      this.ruleForm.remark = "";
      this.ruleForm.selectOperation = 1;
    },
  },
};
</script>

<style lang="scss" scoped>
/deep/ .el-row {
  //margin-bottom: 1.5%;
}
/deep/ .el-upload--picture-card {
  border-radius: 5px;
}
/deep/ .el-form-item__error {
  position: relative;
}
/deep/ .submitClass {
  background: #00be8e !important;
  color: #ffffff !important;
}
/deep/ .el-select__tags {
  overflow: auto;
}
/deep/ .el-button-group > .el-button:not(:last-child) {
  margin-right: 20px;
}
.descOperation {
  height: 38px;
  // color: #ff6a6c;
}
.el-input-hauto /deep/ .el-textarea__inner {
  height: auto;
}
.dialogInput {
  /deep/.el-dialog > .el-dialog__header {
    padding: 12px;
  }
  /deep/.el-dialog > .el-dialog__body {
    padding: 12px 54px 0;
  }
  /deep/.el-textarea__inner {
    height: 60px;
    width: 360px;
  }
  /deep/.el-form .el-form-item.el-form-item--small {
    margin-bottom: 12px !important;
  }
  /deep/.el-dialog {
    border-radius: 4px;
  }
  /deep/.el-form .el-form-item .el-form-item__label {
    //margin-right: 12px;
    //padding-right: 6px;
  }
}
.formSpan {
  color: #909399;
  margin: 0 19px 12px;
  font-size: 12px;
}
/deep/ .el-form .el-form-item .el-form-item__label {
  font-weight: 400 !important;
}
/deep/ .el-radio__input.is-checked + .el-radio__label {
  color: #606266;
}
/deep/ .el-radio__label {
  padding-left: 6px;
}
/deep/ .el-textarea__inner {
  padding: 6px 12px;
  font-size: 14px;
}
/deep/ .el-form .el-form-item .el-form-item__content {
  padding-left: 6px;
}
/deep/ .el-radio {
  margin-right: 24px;
}
</style>
